This section shows the Pascal data structure for the GDevice record, which can contain information about a video device or an offscreen graphics world. This section also shows the data structure for the DeviceLoopFlags data type, which defines a set of options you can specify to the DeviceLoop procedure.
Color QuickDraw stores state information for video devices and offscreen graphics worlds in GDevice records. When the system starts up, it allocates and initializes one handle to a GDevice record for each video device it finds. When you use the NewGWorld function (described in the chapter "Offscreen Graphics Worlds" in this book), Color QuickDraw automatically creates a GDevice record for the new offscreen graphics world. The system links these GDevice records in a list, called the device list . (You can find a handle to the first element in the device list in the global variable DeviceList .) By default, the GDevice record corresponding to the first video device found is marked as the current device; all other graphics devices in the list are initially marked as inactive.
Printing graphics ports, described in the chapter "Printing Manager" in this book, do not have GDevice records.
When the user moves a window or creates a window on another screen, and your application draws into that window, Color QuickDraw automatically makes the video device for that screen the current device. Color QuickDraw stores that information in the global variable TheGDevice .
GDevice records that correspond to video devices have drivers associated with them. These drivers can be used to change the mode of the video device from black and white to color and to change the pixel depth. The set of routines supported by a video driver is defined and described in Designing Cards and Drivers for the Macintosh Family , third edition. Application-created GDevice records usually don't require drivers.
A GDevice record is defined as follows:
TYPE GDevice =
RECORD
gdRefNum: Integer; {reference number of screen }
{ driver}
gdID: Integer; {reserved; set to 0}
gdType: Integer; {device type--indexed or direct}
gdITable: ITabHandle; {handle to inverse table for }
{ Color Manager}
gdResPref: Integer; {preferred resolution}
gdSearchProc: SProcHndl; {handle to list of search }
{ functions}
gdCompProc: CProcHndl; {handle to list of complement }
{ functions}
gdFlags: Integer; {graphics device flags}
gdPMap: PixMapHandle; {handle to PixMap record for }
{ displayed image}
gdRefCon: LongInt; {reference value}
gdNextGD: GDHandle; {handle to next graphics device}
gdRect: Rect; {graphics device's global bounds}
gdMode: LongInt; {graphics device's current mode}
gdCCBytes: Integer; {width of expanded cursor data}
gdCCDepth: Integer; {depth of expanded cursor data}
gdCCXData: Handle; {handle to cursor's expanded }
{ data}
gdCCXMask: Handle; {handle to cursor's expanded }
{ mask}
gdReserved: LongInt; {reserved for future use--must }
{ be 0}
END;
CONST
clutType = 0; {CLUT device--that is, one with }
{ colors mapped with a color }
{ lookup table}
fixedType = 1; {fixed colors--that is, the }
{ color lookup table can't }
{ be changed}
directType = 2; {direct RGB colors}
CONST {flag bits for gdFlags field of GDevice record}
gdDevType = 0; {if bit is set to 0, graphics device is }
{ black and white; if set to 1, }
{ graphics device supports color}
burstDevice = 7; {if bit is set to 1, graphics device }
{ supports block transfer}
ext32Device = 8; {if bit is set to 1, graphics device }
{ must be used in 32-bit mode}
ramInit = 10; {if bit is set to 1, graphics device has }
{ been initialized from RAM}
mainScreen = 11; {if bit is set to 1, graphics device is }
{ the main screen}
allInit = 12; {if bit is set to 1, all graphics devices }
{ were initialized from 'scrn' resource}
screenDevice = 13; {if bit is set to 1, graphics device is }
{ a screen}
noDriver = 14; {if bit is set to 1, GDevice }
{ record has no driver}
screenActive = 15; {if bit is set to 1, graphics device is }
{ active}
Your application should never need to directly change the fields of a GDevice record. If you find it absolutely necessary for your application to so, immediately use the GDeviceChanged procedure to notify Color QuickDraw that your application has changed the GDevice record. The GDeviceChanged procedure is described in the chapter "Color QuickDraw" in this book.
When you use the DeviceLoop procedure (described on DeviceLoop ), you can change its default behavior by using the flags parameter to specify one or more members of the set of flags defined by the DeviceLoopFlags data type. These flags are described here; if you want to use the default behavior of DeviceLoop , pass in the flags parameter 0 in your C code or an empty set ([ ]) in your Pascal code.
TYPE DeviceLoopFlags =
SET OF {for flags parameter of DeviceLoop}
(singleDevices, {DeviceLoop doesn't group similar graphics }
{ devices when calling drawing procedure}
dontMatchSeeds, {DeviceLoop doesn't consider ctSeed fields }
{ of ColorTable records for graphics }
{ devices when comparing them}
allDevices); {DeviceLoop ignores value of drawingRgn }
{ parameter--instead, it calls drawing }
{ procedure for every screen}